package com.kucai.yifaqapp.ui.activity;

import android.app.AlertDialog;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.kucai.yifaqapp.R;
import com.kucai.yifaqapp.dagger.component.activity.DaggerGameDetailsActivityComponent;
import com.kucai.yifaqapp.dagger.module.activity.GameDetailsActivityModule;
import com.kucai.yifaqapp.global.Info;
import com.kucai.yifaqapp.model.network.entity.res.IsHasQipaiBean;
import com.kucai.yifaqapp.presenter.activity.GameDetailsActivityPesenter;
import com.kucai.yifaqapp.ui.fragment.z_gameFragment;
import com.kucai.yifaqapp.ui.fragment.z_planFragment;
import com.kucai.yifaqapp.ui.view.GameDetailsView;
import com.kucai.yifaqapp.util.EventBus.goTomoneyEvent;
import com.kucai.yifaqapp.util.EventBus.showdialog;
import com.kucai.yifaqapp.util.SYSOUtils;
import com.kucai.yifaqapp.util.Timeutils;
import com.kucai.yifaqapp.widget.BaseLoadingDialog;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

import static com.kucai.yifaqapp.global.App.getContext;

/**
 * Created by admin on 2018/12/7.
 */

public class GameDetailActivityFinal extends BaseActivity<GameDetailsActivityPesenter> implements GameDetailsView, View.OnClickListener {
    TextView my_touzhu1;//我的投注
    TextView my_touzhu2;//计划交流
    LinearLayout skinbg;
    private Fragment gameFragment = new z_gameFragment();
    private Fragment planFragment = new z_planFragment();
    private Boolean flag = false;
    private AlertDialog dialog1;
    public String gameid;  //顺便提供给fragment用
    public String money;  //顺便提供给fragment用
    public static String webvideo;  //顺便提供给fragment用
    TextView backTv;
    ImageView backIv;
    public TextView moneyTv;
    ImageView moreIv;
    WebView webview_zhibo;
    RelativeLayout webview_content;
    LinearLayout kaijiangzhibo;//直播
    private boolean isPlay = false;
    private boolean isfirstload = true;

    @Override
    protected int setContentView() {
        return R.layout.game_detail_final;
    }

    @Override
    protected void ChangeSkin() {
        switch (SkinId) {
            case 17771:
                skinbg.setBackgroundResource(R.mipmap.skin_bg1);
                break;
            case 17772:
                skinbg.setBackgroundResource(R.mipmap.skin_bg2);
                break;
            case 17773:
                skinbg.setBackgroundResource(R.mipmap.skin_bg3);
                break;
            default:
                skinbg.setBackgroundResource(R.mipmap.skin_bg1);
        }
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        ButterKnife.bind(this);
        dialog=new BaseLoadingDialog(this,R.style.CustomDialog);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
        my_touzhu1 = findViewById(R.id.my_touzhu1);
        my_touzhu2 = findViewById(R.id.my_touzhu2);
        skinbg = findViewById(R.id.skinbg);
        backTv = findViewById(R.id.back_tv);
        backIv = findViewById(R.id.back_iv);
        moneyTv = findViewById(R.id.money_tv);
        moreIv = findViewById(R.id.more_iv);
        webview_zhibo = findViewById(R.id.webview_zhibo);
        webview_content = findViewById(R.id.webview_content);
        kaijiangzhibo = findViewById(R.id.kaijiangzhibo);

        initWebview();
        initChat();
        initEvent();
        initPopuWindow1(moreIv);
        popuWindow1.dismiss();
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
        Intent intent = getIntent();
        gameid = intent.getStringExtra("gameid");
        backTv.setText(intent.getStringExtra("gamename"));

        //创建游戏规则弹框
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        switch (Integer.parseInt(gameid)) {
            case 80:
                View view = View.inflate(this, R.layout.miaosusaichepop_layout, null);
                builder.setView(view);
                TextView game_pop_canclbt = (TextView) view.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt = (TextView) view.findViewById(R.id.game_pop_yesbt);
                TextView guanwang = (TextView) view.findViewById(R.id.guanwang);
                if (Info.offurl != null && Info.offurl.size() != 0) {
                    for (Map.Entry<String, String> entry : Info.offurl.entrySet()) {
                        if (entry.getKey().equals("80")) {
                            if (!entry.getValue().equals("[]")) {
                                guanwang.setVisibility(View.VISIBLE);
                                guanwang.setText("官网:" + entry.getValue());
                            } else {
                                guanwang.setVisibility(View.GONE);
                            }
                        }
                    }
                }
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
//                SYSOUtils.sOut_("111111111111111111" + OFFurl);
                //秒速赛车赔率
                break;
            case 801:
                View view26 = View.inflate(this, R.layout.kuaisusaichepop_layout, null);
                builder.setView(view26);
                TextView game_pop_canclbt26 = (TextView) view26.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt26 = (TextView) view26.findViewById(R.id.game_pop_yesbt);
                TextView guanwang26 = (TextView) view26.findViewById(R.id.guanwang);
                if (Info.offurl != null && Info.offurl.size() != 0) {
                    for (Map.Entry<String, String> entry : Info.offurl.entrySet()) {
                        if (entry.getKey().equals("801")) {
                            if (!entry.getValue().equals("[]")) {
                                guanwang26.setVisibility(View.VISIBLE);
                                guanwang26.setText("官网:" + entry.getValue());
                            } else {
                                guanwang26.setVisibility(View.VISIBLE);
                            }
                        } else {
                            guanwang26.setVisibility(View.VISIBLE);
                        }
                    }
                }                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt26.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt26.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
//                SYSOUtils.sOut_("111111111111111111" + OFFurl);
                //秒速赛车赔率
                break;
            case 50:
                //北京赛车
                View view1 = View.inflate(this, R.layout.beijingsaichepop, null);
                builder.setView(view1);
                TextView game_pop_canclbt1 = (TextView) view1.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt1 = (TextView) view1.findViewById(R.id.game_pop_yesbt);
                TextView guanwang1 = (TextView) view1.findViewById(R.id.guanwang);
                if (Info.offurl != null && Info.offurl.size() != 0) {
                    for (Map.Entry<String, String> entry : Info.offurl.entrySet()) {
                        if (entry.getKey().equals("50")) {
                            if (!entry.getValue().equals("[]")) {
                                guanwang1.setVisibility(View.VISIBLE);
                                guanwang1.setText("官网:" + entry.getValue());
                            } else {
                                guanwang1.setVisibility(View.GONE);
                            }
                        }
                    }
                }
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt1.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt1.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 55:
                //幸运飞艇
                View viewxy = View.inflate(this, R.layout.xyfeitingpop, null);
                builder.setView(viewxy);
                TextView game_pop_canclbtxy = (TextView) viewxy.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbtxy = (TextView) viewxy.findViewById(R.id.game_pop_yesbt);
                TextView guanwangxy = (TextView) viewxy.findViewById(R.id.guanwang);
                if (Info.offurl != null && Info.offurl.size() != 0) {
                    for (Map.Entry<String, String> entry : Info.offurl.entrySet()) {
                        if (entry.getKey().equals("55")) {
                            if (!entry.getValue().equals("[]")) {
                                guanwangxy.setVisibility(View.VISIBLE);
                                guanwangxy.setText("官网:" + entry.getValue());
                            } else {
                                guanwangxy.setVisibility(View.GONE);
                            }
                        }
                    }
                }
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbtxy.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbtxy.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 82:
                //秒速快艇
                View view2 = View.inflate(this, R.layout.miaosufeitingpop, null);
                builder.setView(view2);
                TextView game_pop_canclbt2 = (TextView) view2.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt2 = (TextView) view2.findViewById(R.id.game_pop_yesbt);
                TextView guanwang2 = (TextView) view2.findViewById(R.id.guanwang);
                if (Info.offurl != null && Info.offurl.size() != 0) {
                    for (Map.Entry<String, String> entry : Info.offurl.entrySet()) {
                        if (entry.getKey().equals("82")) {
                            if (!entry.getValue().equals("[]")) {
                                guanwang2.setVisibility(View.VISIBLE);
                                guanwang2.setText("官网:" + entry.getValue());
                            } else {
                                guanwang2.setVisibility(View.GONE);
                            }
                        }
                    }
                }
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt2.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt2.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 802:
                //秒速快艇
                View view27 = View.inflate(this, R.layout.kuaisufeitingpop, null);
                builder.setView(view27);
                TextView game_pop_canclbt27 = (TextView) view27.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt27 = (TextView) view27.findViewById(R.id.game_pop_yesbt);
                TextView guanwang27 = (TextView) view27.findViewById(R.id.guanwang);
                if (Info.offurl != null && Info.offurl.size() != 0) {
                    for (Map.Entry<String, String> entry : Info.offurl.entrySet()) {
                        if (entry.getKey().equals("802")) {
                            if (!entry.getValue().equals("[]")) {
                                guanwang27.setVisibility(View.VISIBLE);
                                guanwang27.setText("官网:" + entry.getValue());
                            } else {
                                guanwang27.setVisibility(View.VISIBLE);
                            }
                        } else {
                            guanwang27.setVisibility(View.VISIBLE);
                        }
                    }
                }
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt27.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt27.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 99:
                //香港跑马
                View view3 = View.inflate(this, R.layout.xainggangpaomapop, null);
                builder.setView(view3);
                TextView game_pop_canclbt3 = (TextView) view3.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt3 = (TextView) view3.findViewById(R.id.game_pop_yesbt);
                TextView guanwang3 = (TextView) view3.findViewById(R.id.guanwang);
                if (Info.offurl != null && Info.offurl.size() != 0) {
                    for (Map.Entry<String, String> entry : Info.offurl.entrySet()) {
                        if (entry.getKey().equals("99")) {
                            if (!entry.getValue().equals("[]")) {
                                guanwang3.setVisibility(View.VISIBLE);
                                guanwang3.setText("官网:" + entry.getValue());
                            } else {
                                guanwang3.setVisibility(View.GONE);
                            }
                        }
                    }
                }
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt3.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt3.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 81:
                //秒速时时彩
                View view4 = View.inflate(this, R.layout.miaosushishicaipop, null);
                builder.setView(view4);
                TextView game_pop_canclbt4 = (TextView) view4.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt4 = (TextView) view4.findViewById(R.id.game_pop_yesbt);
                TextView guanwang4 = (TextView) view4.findViewById(R.id.guanwang);
                if (Info.offurl != null && Info.offurl.size() != 0) {
                    for (Map.Entry<String, String> entry : Info.offurl.entrySet()) {
                        if (entry.getKey().equals("81")) {
                            if (!entry.getValue().equals("[]")) {
                                guanwang4.setVisibility(View.VISIBLE);
                                guanwang4.setText("官网:" + entry.getValue());
                            } else {
                                guanwang4.setVisibility(View.GONE);
                            }
                        }
                    }
                }
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt4.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt4.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 803:
                //秒速时时彩
                View view28 = View.inflate(this, R.layout.kuaisushishicaipop, null);
                builder.setView(view28);
                TextView game_pop_canclbt28 = (TextView) view28.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt28 = (TextView) view28.findViewById(R.id.game_pop_yesbt);
                TextView guanwang28 = (TextView) view28.findViewById(R.id.guanwang);
                if (Info.offurl != null && Info.offurl.size() != 0) {
                    for (Map.Entry<String, String> entry : Info.offurl.entrySet()) {
                        if (entry.getKey().equals("803")) {
                            if (!entry.getValue().equals("[]")) {
                                guanwang28.setVisibility(View.VISIBLE);
                                guanwang28.setText("官网:" + entry.getValue());
                            } else {
                                guanwang28.setVisibility(View.VISIBLE);
                            }
                        } else {
                            guanwang28.setVisibility(View.VISIBLE);
                        }
                    }
                }
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt28.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt28.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 1:
                //重庆时时彩
                View view5 = View.inflate(this, R.layout.chongqingshishicaipop, null);
                builder.setView(view5);
                TextView game_pop_canclbt5 = (TextView) view5.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt5 = (TextView) view5.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt5.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt5.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 4:
                //新疆时时彩
                View view6 = View.inflate(this, R.layout.xinjiangshishicaipop, null);
                builder.setView(view6);
                TextView game_pop_canclbt6 = (TextView) view6.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt6 = (TextView) view6.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt6.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt6.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 91:
                //秒速牛牛
                View view7 = View.inflate(this, R.layout.miaosuniuniupop, null);
                builder.setView(view7);
                TextView game_pop_canclbt7 = (TextView) view7.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt7 = (TextView) view7.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt7.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt7.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 90:

                //pk10牛牛
                View view8 = View.inflate(this, R.layout.pk10niuniupop, null);
                builder.setView(view8);
                TextView game_pop_canclbt8 = (TextView) view8.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt8 = (TextView) view8.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt8.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt8.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 66:
                //pc蛋蛋
                View view9 = View.inflate(this, R.layout.pcdandanpop, null);
                builder.setView(view9);
                TextView game_pop_canclbt9 = (TextView) view9.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt9 = (TextView) view9.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt9.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt9.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 65:
                //快乐北京8
                View view10 = View.inflate(this, R.layout.kuailebeijing8pop, null);
                builder.setView(view10);
                TextView game_pop_canclbt10 = (TextView) view10.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt10 = (TextView) view10.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt10.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt10.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 86:
                //秒速快三
                View view18 = View.inflate(this, R.layout.miaosukuaisanpop, null);
                builder.setView(view18);
                TextView game_pop_canclbt18 = (TextView) view18.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt18 = (TextView) view18.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt18.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt18.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 10:
                //江苏快三
                View view11 = View.inflate(this, R.layout.jiangsukuaisanpop, null);
                builder.setView(view11);
                TextView game_pop_canclbt11 = (TextView) view11.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt11 = (TextView) view11.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt11.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt11.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 12:
                //广西快三
                View view12 = View.inflate(this, R.layout.guangxikuaisanpop, null);
                builder.setView(view12);
                TextView game_pop_canclbt12 = (TextView) view12.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt12 = (TextView) view12.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt12.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt12.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 13:
                //湖北快三
                View view13 = View.inflate(this, R.layout.hubeikuaisanpop, null);
                builder.setView(view13);
                TextView game_pop_canclbt13 = (TextView) view13.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt13 = (TextView) view13.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt13.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt13.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 16:
                //甘肃快三
                View view14 = View.inflate(this, R.layout.gansukuaisanpop, null);
                builder.setView(view14);
                TextView game_pop_canclbt14 = (TextView) view14.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt14 = (TextView) view14.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt14.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt14.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 15:
                //河北快三
                View view15 = View.inflate(this, R.layout.hebeikuaisanpop, null);
                builder.setView(view15);
                TextView game_pop_canclbt15 = (TextView) view15.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt15 = (TextView) view15.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt15.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt15.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 18:
                //贵州快三
                View view16 = View.inflate(this, R.layout.guizhoukuaisanpop, null);
                builder.setView(view16);
                TextView game_pop_canclbt16 = (TextView) view16.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt16 = (TextView) view16.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt16.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt16.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;

            case 11:
                //安徽快三
                View view17 = View.inflate(this, R.layout.anhuikuaisanpop, null);
                builder.setView(view17);
                TextView game_pop_canclbt17 = (TextView) view17.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt17 = (TextView) view17.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt17.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt17.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 60:
                //快乐十分
                View view19 = View.inflate(this, R.layout.kuaileshifenpop, null);
                builder.setView(view19);
                TextView game_pop_canclbt19 = (TextView) view19.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt19 = (TextView) view19.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt19.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt19.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 61:
                //幸运农场
                View view20 = View.inflate(this, R.layout.xingyunnongchangpop, null);
                builder.setView(view20);
                TextView game_pop_canclbt20 = (TextView) view20.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt20 = (TextView) view20.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt20.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt20.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 21:
                //十一选五
                View view21 = View.inflate(this, R.layout.shiyixuanwupop, null);
                builder.setView(view21);
                TextView game_pop_canclbt21 = (TextView) view21.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt21 = (TextView) view21.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt21.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt21.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 70:
                //香港六合彩
                View view22 = View.inflate(this, R.layout.xgliuhecaipop, null);
                builder.setView(view22);
                TextView game_pop_canclbt22 = (TextView) view22.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt22 = (TextView) view22.findViewById(R.id.game_pop_yesbt);
                LinearLayout gou = (LinearLayout) view22.findViewById(R.id.gouguize);
                LinearLayout zhu = (LinearLayout) view22.findViewById(R.id.zhuguize);
//                LinearLayout gou1 = (LinearLayout) view22.findViewById(R.id.gouguize1);
//                LinearLayout zhu1 = (LinearLayout) view22.findViewById(R.id.zhuguize1);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
//                //获取系统时间，判断显示猪年还是狗年规则
//                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//                Date curDate = new Date(System.currentTimeMillis());
//                String str = formatter.format(curDate);
//                long serverTime = Timeutils.getStringToDate(str);
//                long changeTime = Timeutils.getStringToDate("2019-02-04 23:59:59");
//                if (serverTime > changeTime) {
//                    zhu.setVisibility(View.VISIBLE);
//                    gou.setVisibility(View.GONE);
//                    zhu1.setVisibility(View.VISIBLE);
//                    gou1.setVisibility(View.GONE);
//                } else {
//                    gou.setVisibility(View.VISIBLE);
//                    zhu.setVisibility(View.GONE);
//                    gou1.setVisibility(View.VISIBLE);
//                    zhu1.setVisibility(View.GONE);
//                }
                game_pop_canclbt22.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt22.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });

                break;

            case 85:
                //幸运六合彩
                View view23 = View.inflate(this, R.layout.xyliuhecaipop, null);
                builder.setView(view23);
                TextView game_pop_canclbt23 = (TextView) view23.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt23 = (TextView) view23.findViewById(R.id.game_pop_yesbt);
                LinearLayout xingyungou = (LinearLayout) view23.findViewById(R.id.gouguize);
                LinearLayout xingyunzhu = (LinearLayout) view23.findViewById(R.id.zhuguize);
//                LinearLayout xingyungou1 = (LinearLayout) view23.findViewById(R.id.gouguize1);
//                LinearLayout xingyunzhu1 = (LinearLayout) view23.findViewById(R.id.zhuguize1);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                //获取系统时间，判断显示猪年还是狗年规则
//                SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//                Date curDate1 = new Date(System.currentTimeMillis());
//                String str1 = formatter1.format(curDate1);
//                long serverTime1 = Timeutils.getStringToDate(str1);
//                long changeTime1 = Timeutils.getStringToDate("2019-02-04 23:59:59");
//                if (serverTime1 > changeTime1) {
//                    xingyunzhu.setVisibility(View.VISIBLE);
//                    xingyungou.setVisibility(View.GONE);
//                    xingyunzhu1.setVisibility(View.VISIBLE);
//                    xingyungou1.setVisibility(View.GONE);
//                } else {
//                    xingyungou.setVisibility(View.VISIBLE);
//                    xingyunzhu.setVisibility(View.GONE);
//                    xingyungou1.setVisibility(View.VISIBLE);
//                    xingyunzhu1.setVisibility(View.GONE);
//                }
                game_pop_canclbt23.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt23.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 112:
                //腾讯分分彩
                View view24 = View.inflate(this, R.layout.tengxunfenfencaipop, null);
                builder.setView(view24);
                TextView game_pop_canclbt24 = (TextView) view24.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt24 = (TextView) view24.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt24.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt24.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;

            case 113:
                //QQ分分彩
                View view25 = View.inflate(this, R.layout.qqfenfencaipop, null);
                builder.setView(view25);
                TextView game_pop_canclbt25 = (TextView) view25.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt25 = (TextView) view25.findViewById(R.id.game_pop_yesbt);
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt25.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt25.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;


            case 804:
                // xingyunfeiting
                View view29 = View.inflate(this, R.layout.xingyunfeitingpop, null);
                builder.setView(view29);
                TextView game_pop_canclbt29 = (TextView) view29.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt29 = (TextView) view29.findViewById(R.id.game_pop_yesbt);
                TextView guanwang29 = (TextView) view29.findViewById(R.id.guanwang);
                if (Info.offurl != null && Info.offurl.size() != 0) {
                    for (Map.Entry<String, String> entry : Info.offurl.entrySet()) {
                        if (entry.getKey().equals("804")) {
                            if (!entry.getValue().equals("[]")) {
                                guanwang29.setVisibility(View.VISIBLE);
                                guanwang29.setText("官网:" + entry.getValue());
                            } else {
                                guanwang29.setVisibility(View.VISIBLE);
                            }
                        } else {
                            guanwang29.setVisibility(View.VISIBLE);
                        }
                    }
                }
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt29.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt29.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;

            case 901:
                // 三分赛车
                View view30 = View.inflate(this, R.layout.sanfensaichepop, null);
                builder.setView(view30);
                TextView game_pop_canclbt30 = (TextView) view30.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt30 = (TextView) view30.findViewById(R.id.game_pop_yesbt);
                TextView guanwang30 = (TextView) view30.findViewById(R.id.guanwang);
                if (Info.offurl != null && Info.offurl.size() != 0) {
                    for (Map.Entry<String, String> entry : Info.offurl.entrySet()) {
                        if (entry.getKey().equals("901")) {
                            if (!entry.getValue().equals("[]")) {
                                guanwang30.setVisibility(View.VISIBLE);
                                guanwang30.setText("官网:" + entry.getValue());
                            } else {
                                guanwang30.setVisibility(View.VISIBLE);
                            }
                        } else {
                            guanwang30.setVisibility(View.VISIBLE);
                        }
                    }
                }
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt30.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt30.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 902:
                // 三分时时彩
                View view31 = View.inflate(this, R.layout.sanfenshishicaipop, null);
                builder.setView(view31);
                TextView game_pop_canclbt31 = (TextView) view31.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt31 = (TextView) view31.findViewById(R.id.game_pop_yesbt);
                TextView guanwang31 = (TextView) view31.findViewById(R.id.guanwang);
                if (Info.offurl != null && Info.offurl.size() != 0) {
                    for (Map.Entry<String, String> entry : Info.offurl.entrySet()) {
                        if (entry.getKey().equals("902")) {
                            if (!entry.getValue().equals("[]")) {
                                guanwang31.setVisibility(View.VISIBLE);
                                guanwang31.setText("官网:" + entry.getValue());
                            } else {
                                guanwang31.setVisibility(View.VISIBLE);
                            }
                        } else {
                            guanwang31.setVisibility(View.VISIBLE);
                        }
                    }
                }
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt31.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt31.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 903:
                // 急速六合彩
                View view32 = View.inflate(this, R.layout.jisuliuhecaipop, null);
                builder.setView(view32);
                TextView game_pop_canclbt32 = (TextView) view32.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt32 = (TextView) view32.findViewById(R.id.game_pop_yesbt);
                TextView guanwang32 = (TextView) view32.findViewById(R.id.guanwang);
                if (Info.offurl != null && Info.offurl.size() != 0) {
                    for (Map.Entry<String, String> entry : Info.offurl.entrySet()) {
                        if (entry.getKey().equals("903")) {
                            if (!entry.getValue().equals("[]")) {
                                guanwang32.setVisibility(View.VISIBLE);
                                guanwang32.setText("官网:" + entry.getValue());
                            } else {
                                guanwang32.setVisibility(View.VISIBLE);
                            }
                        } else {
                            guanwang32.setVisibility(View.VISIBLE);
                        }
                    }
                }
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt32.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt32.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;
            case 904:
                // 三分六合彩
                View view33 = View.inflate(this, R.layout.husuliuhecaipop, null);
                builder.setView(view33);
                TextView game_pop_canclbt33 = (TextView) view33.findViewById(R.id.game_pop_canclbt);
                TextView game_pop_yesbt33 = (TextView) view33.findViewById(R.id.game_pop_yesbt);
                TextView guanwang33 = (TextView) view33.findViewById(R.id.guanwang);
                if (Info.offurl != null && Info.offurl.size() != 0) {
                    for (Map.Entry<String, String> entry : Info.offurl.entrySet()) {
                        if (entry.getKey().equals("904")) {
                            if (!entry.getValue().equals("[]")) {
                                guanwang33.setVisibility(View.VISIBLE);
                                guanwang33.setText("官网:" + entry.getValue());
                            } else {
                                guanwang33.setVisibility(View.VISIBLE);
                            }
                        } else {
                            guanwang33.setVisibility(View.VISIBLE);
                        }
                    }
                }
                //创建适配器
                dialog1 = builder.create();
                dialog1.setCancelable(true);//点击外边缘隐藏
                game_pop_canclbt33.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                game_pop_yesbt33.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog1.dismiss();
                    }
                });
                break;

            default:
                Toast.makeText(getContext(), "传入游戏id暂未设置游戏规则", Toast.LENGTH_SHORT).show();
                break;

        }
        if (null != Info.user && null != Info.user.money)

        {
            moneyTv.setText(Info.user.money);
        }

    }

    private void initChat() {
        if (IsHasQipaiBean.ishasChat) {
            my_touzhu2.setVisibility(View.VISIBLE);
        } else {
            my_touzhu2.setVisibility(View.GONE);
        }
    }

    private void initWebview() {
        WebSettings webSettings = webview_zhibo.getSettings();
        webSettings.setJavaScriptEnabled(true);//允许运行JavaScript
        webSettings.setDomStorageEnabled(true);
        //不支持缓存
        webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
        //支持屏幕缩放
        webSettings.setSupportZoom(true);
        webSettings.setBuiltInZoomControls(true);
        String ua = webview_zhibo.getSettings().getUserAgentString();
        webview_zhibo.getSettings().setUserAgentString(ua + "; 自定义标记");
        webview_zhibo.setWebViewClient(new WebViewClient() {

            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                if (url.startsWith("http:") || url.startsWith("https:")) {
                    return false;
                }
                return true;
            }
        });
        webview_zhibo.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                // 获得网页的加载进度 newProgress为当前加载百分比
                super.onProgressChanged(view, newProgress);
            }

            @Override
            public void onReceivedTitle(WebView view, String title) {
                super.onReceivedTitle(view, title);
            }
        });
    }

    @Override
    protected void initDagger() {
        DaggerGameDetailsActivityComponent.builder()
                .gameDetailsActivityModule(new GameDetailsActivityModule(this))
                .build().inject(this);
    }

    private void initEvent() {
        my_touzhu2.setOnClickListener(this);
        my_touzhu1.setOnClickListener(this);
        backTv.setOnClickListener(this);
        backIv.setOnClickListener(this);
        moreIv.setOnClickListener(this);
        webview_zhibo.setOnClickListener(this);
        kaijiangzhibo.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.my_touzhu1:
                changeFragmemt("1");
                my_touzhu1.setBackgroundColor(getContext().getResources().getColor(R.color.transparent_background));
                my_touzhu2.setBackgroundColor(getContext().getResources().getColor(R.color.background));
                break;
            case R.id.my_touzhu2:
                changeFragmemt("2");
                my_touzhu2.setBackgroundColor(getContext().getResources().getColor(R.color.transparent_background));
                my_touzhu1.setBackgroundColor(getContext().getResources().getColor(R.color.background));
                break;
            case R.id.back_tv:
                finish();
                startActivity(new Intent(getContext(), AlllotteryActivity.class));
                break;
            case R.id.back_iv:
                finish();
                startActivity(new Intent(getContext(), AlllotteryActivity.class));
                break;
            case R.id.more_iv:
                if (popuWindow1.isShowing()) {
                    popuWindow1.dismiss();
                } else {
                    popuWindow1.showAsDropDown(moreIv, 0, 0);
                    popuWindow1.update();
                    WindowManager.LayoutParams lp = getWindow().getAttributes();
                    lp.alpha = 0.4f;
                    getWindow().setAttributes(lp);
                }
                break;
            case R.id.kaijiangzhibo:
                if (!TextUtils.isEmpty(webvideo)) {
                    if (!isPlay) {
                        isPlay = true;
                        webview_content.setVisibility(View.VISIBLE);
                        webview_zhibo.loadUrl(webvideo);
                    } else {
                        webview_zhibo.loadUrl("");
                        webview_content.setVisibility(View.GONE);
                        isPlay = false;
                    }
                } else {
                    Toast.makeText(getContext(), "暂未开放", Toast.LENGTH_SHORT).show();
                }
                break;
        }
    }
    //在activity开始显示后才加载fragment


    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        if (hasFocus) {
            //开始初始化fragment
            if (isfirstload) {
                initFragment();
                isfirstload = false;
            }
        }
    }

    private void initFragment() {
        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        if (!gameFragment.isAdded()) {
            ft.add(R.id.content, gameFragment, "1");
        }
        if (!planFragment.isAdded()) {
            ft.add(R.id.content, planFragment, "2");
        }
        ft.commitAllowingStateLoss();
        changeFragmemt("1");
    }

    public void changeFragmemt(String tag) {
        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        if (tag.equals("1")) {
            ft.show(gameFragment);
            ft.hide(planFragment);
        } else if (tag.equals("2")) {
            ft.show(planFragment);
            ft.hide(gameFragment);
        }
        ft.commitAllowingStateLoss();
    }

    PopupWindow popuWindow1 = null;

    private void initPopuWindow1(View parent) {
        View contentView1 = null;
        if (popuWindow1 == null) {
            LayoutInflater mLayoutInflater = LayoutInflater.from(this);
            contentView1 = mLayoutInflater.inflate(R.layout.pop_window_game_details, null);
            popuWindow1 = new PopupWindow(contentView1, ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT);
        }

        ColorDrawable cd = new ColorDrawable(0xff0000);
        popuWindow1.setBackgroundDrawable(cd);
        popuWindow1.setOutsideTouchable(false);
        popuWindow1.setFocusable(false);
        popuWindow1.setOnDismissListener(new PopupWindow.OnDismissListener() {

            //在dismiss中恢复透明度
            public void onDismiss() {
                WindowManager.LayoutParams lp = getWindow().getAttributes();
                lp.alpha = 1f;
                getWindow().setAttributes(lp);
            }
        });

        TextView instancorder = contentView1.findViewById(R.id.instancorder);
        TextView todayover = contentView1.findViewById(R.id.todayover);
        TextView addorder = contentView1.findViewById(R.id.addorder);
        TextView opengame = contentView1.findViewById(R.id.opengame);
        TextView gamerule = contentView1.findViewById(R.id.gamerule);
        TextView twolong = contentView1.findViewById(R.id.twolong);
        TextView luzhu = contentView1.findViewById(R.id.luzhu);
        TextView todaywin = contentView1.findViewById(R.id.todaywin);
        View cancle = contentView1.findViewById(R.id.cancle);
        View tixian = contentView1.findViewById(R.id.tixian);
        View chongzhi = contentView1.findViewById(R.id.chongzhi);
        RelativeLayout content = contentView1.findViewById(R.id.content);
        tixian.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Info.user.userName != null) {
                    EventBus.getDefault().post(new goTomoneyEvent("3"));
                    finish();
                } else {
                    Toast.makeText(GameDetailActivityFinal.this, "请注册为正式账号", Toast.LENGTH_SHORT).show();
                }
                popuWindow1.dismiss();
            }
        });
        chongzhi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Info.user.userName != null) {
                    EventBus.getDefault().post(new goTomoneyEvent("3"));
                    finish();
                } else {
                    Toast.makeText(GameDetailActivityFinal.this, "请注册为正式账号", Toast.LENGTH_SHORT).show();
                }
                popuWindow1.dismiss();
            }
        });
        cancle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popuWindow1.dismiss();
            }
        });
        instancorder.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popuWindow1.dismiss();
                startActivity(new Intent(GameDetailActivityFinal.this, NoteActivity.class));
            }
        });
        final PopupWindow finalPopuWindow = popuWindow1;
        todayover.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popuWindow1.dismiss();
                startActivity(new Intent(GameDetailActivityFinal.this, NowActivity.class));
            }
        });
        addorder.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popuWindow1.dismiss();
                startActivity(new Intent(GameDetailActivityFinal.this, RecrdActivity.class));
            }
        });
        opengame.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popuWindow1.dismiss();
                Intent intent = new Intent(GameDetailActivityFinal.this, LotteryopenActivity.class);
                intent.putExtra("gameid", gameid);
                intent.putExtra("gamename", backTv.getText().toString().trim());
                startActivity(intent);
            }
        });
        gamerule.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (dialog1 != null) {
                    dialog1.show();
                }
                popuWindow1.dismiss();
            }
        });

        twolong.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popuWindow1.dismiss();
                if (gameid.equals("80") || gameid.equals("50") || gameid.equals("82") || gameid.equals("99")) {
                    Intent intent1 = new Intent(GameDetailActivityFinal.this, LongsidesActivity.class);
                    intent1.putExtra("gameid", gameid);
//                    intent1.putExtra("gamename", backTv.getText().toString().trim());
                    startActivity(intent1);
                } else {
                    Toast.makeText(GameDetailActivityFinal.this, "此彩种暂无长龙数据", Toast.LENGTH_SHORT).show();
                }
            }
        });
        luzhu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popuWindow1.dismiss();
                if (gameid.equals("80") || gameid.equals("81") || gameid.equals("50") || gameid.equals("82") || gameid.equals("99")
                        || gameid.equals("1") || gameid.equals("65") || gameid.equals("60") || gameid.equals("61") || gameid.equals("21")) {
                    Intent intent1 = new Intent(GameDetailActivityFinal.this, LuzhuActivity.class);
                    intent1.putExtra("gameid", gameid);
                    intent1.putExtra("gamename", backTv.getText().toString().trim());
                    startActivity(intent1);
                } else {
                    Toast.makeText(GameDetailActivityFinal.this, "此彩种暂无路珠数据", Toast.LENGTH_SHORT).show();
                }
            }
        });
        todaywin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popuWindow1.dismiss();
                startActivity(new Intent(GameDetailActivityFinal.this, NowActivity.class));
            }
        });
        content.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popuWindow1.dismiss();
            }
        });
    }

    BaseLoadingDialog dialog;
    //这里开始设置显示开奖
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void Event(showdialog messageEvent) {
        if(messageEvent.getMessage().equals("0")){
            if(dialog!=null){
                dialog.show();
            }
        }else {
            if(dialog!=null){
                dialog.dismiss();
            }
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}
